﻿function SaveComment()
{ 
    $.ajax({
        async: true,
        type: "POST",
        url:  prependOrgName("/topiclist.aspx"),
        data: {
            otype:                  "savecomment",  
            title:                  $("#txtTitle").val(),
            comments:               $("#txtComments").val(), 
            author:                 $("#txtAuthor").val()
        },
        beforeSend: function() { 
            $("#loading1").css("display", "");
        },
        success: function(data, textStatus) {
            $("#loading1").css("display", "none");
            if(data == "succeeded")
            {
                alert("发布成功！");
                LoadingCommentsList("divcommentslist");
                $("#txtTitle").val("");
                $("#txtComments").val("");
                $("#txtAuthor").val("");
            }
            else
            {
                alert(data);
            }
        }
    });
}
function SaveReply()
{
    $.ajax({
        async: true,
        type: "POST",
        url:  prependOrgName("/website_admin/bbs/topic_replies.aspx"),
        data: {
            otype:                  "savereply",
            comments:               $("#txtComments").val(), 
            author:                 $("#txtAuthor").val(),
            b_id:                   getUrlParam("b_id")
        },
        beforeSend: function() { 
            $("#loading1").css("display", "");
        },
        success: function(data, textStatus) {
            $("#loading1").css("display", "none");
            if(data == "succeeded")
            {
                alert("回复提交成功！");
                LoadingRepliesList("divcommentslist"); 
                $("#txtComments").val(""); 
            }
            else
            {
                alert(data);
            }
        }
    });
}
function LoadingRepliesList(tagObjectId)
{
    $.ajax({
        async: true,
        type: "POST",
        url:  prependOrgName("/website_admin/bbs/topic_replies.aspx"),
        data: {
            otype:          "loadingreplies",
            b_id:          getUrlParam("b_id")
        },
        beforeSend: function() {
            $("#"+tagObjectId).html("");
            $("#"+tagObjectId).html($("#loading1").html());
        },
        success: function(data, textStatus) {  
            $("#"+tagObjectId).html("");
            $("#"+tagObjectId).html(data);
        }
    });
    GetRepliesCount();
}
function GetRepliesCount()
{
    $.ajax({
        async: true,
        type: "POST",
        url:  prependOrgName("/website_admin/bbs/topic_replies.aspx"),
        data: {
            otype:          "getrepliescount",
            b_id:          getUrlParam("b_id")
        }, 
        success: function(data, textStatus) {   
            $("#repliescount").html(data);
        }
    });
}
function DeleteReplies(objectid)
{
    $.ajax({
        async: true,
        type: "POST",
        url:  prependOrgName("/website_admin/bbs/topic_replies.aspx"),
        data: {
            otype:          "delete",
            b_id:          getUrlParam("b_id"),
            r_id:          objectid
        }, 
        success: function(data, textStatus) { 
            if(data == "succeeded")
            {
                alert("删除成功！");
                LoadingRepliesList("divcommentslist");
            }
            else
            { 
                alert("操作失败！");
            }
        }
    });
}